package com.bjc.sdx.activity;

import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;

import com.bjc.sdx.R;

public class MyBBreceiverActivity2 extends AppCompatActivity {
    private Button btn;
    private final String TAG = "MyBBreceiverActivity2";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.receiver_layout);
        btn = findViewById(R.id.button2);
        btn.setOnClickListener(new View.OnClickListener(){

            @Override
            public void onClick(View view) {
                Intent intent = new Intent();
                intent.setAction("callme");
                intent.setComponent(new ComponentName("com.bjc.sdx","com.bjc.sdx.utils.MyBRReceiver"));
                Log.d(TAG, "onClick: setComponent--->\"com.bjc.sdx.utils.MyBRReceiver\"");
                //ComponentName 参数1：接收方App包名，参数2：接收类名
                sendBroadcast(intent);
            }
        });
    }
}
